package com.higgins.eventtracking.client.finance;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.user.client.ui.DockLayoutPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootLayoutPanel;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.TabPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;

public class Finance implements EntryPoint {

	@SuppressWarnings({ "unchecked", "rawtypes" })
	public void onModuleLoad() {
		TabPanel tabPanel = new TabPanel();
		tabPanel.setSize("250em","100em");
		final FinanceAddTransaction addTransactionPanel = new FinanceAddTransaction();
		tabPanel.add(addTransactionPanel, "Add Transaction");
		addTransactionPanel.update();

		final OutstandingTransactionsTab outstandingTransactionsPanel = new OutstandingTransactionsTab();
		tabPanel.add(outstandingTransactionsPanel, "Outstanding Transactions");
		
		final Transactions transactionPanel = new Transactions();
		tabPanel.add(transactionPanel, "Transactions");

		final Assets assetPanel = new Assets();
		tabPanel.add(assetPanel, "Asset Statement");
		
		final Income incomePanel = new Income();
		tabPanel.add(incomePanel, "Income");
		
		final FixedOutgoingTab fixedOutGoingPanel = new FixedOutgoingTab();
		tabPanel.add(fixedOutGoingPanel, "Fixed Outgoing");
		
		final Charts chartsPanel = new Charts();
		tabPanel.add(chartsPanel, "Charts");
		
		final Goals goalsPanel = new Goals();
		tabPanel.add(goalsPanel, "Goals");
		
		tabPanel.selectTab(0);
		RootLayoutPanel.get().add(tabPanel);
		
		tabPanel.addSelectionHandler(new SelectionHandler<Integer>() {
            @Override
            public void onSelection(SelectionEvent<Integer> integerSelectionEvent) {

                if (integerSelectionEvent.getSelectedItem() == 0)	{
                	addTransactionPanel.update();
                }
                if (integerSelectionEvent.getSelectedItem() == 1)	{
                	outstandingTransactionsPanel.update();
                }
                if (integerSelectionEvent.getSelectedItem() == 2)	{
                	transactionPanel.update();
                }
                if (integerSelectionEvent.getSelectedItem() == 3)	{
                	assetPanel.update();
                }
                if (integerSelectionEvent.getSelectedItem() == 4)	{
                	incomePanel.update();
                }
                if (integerSelectionEvent.getSelectedItem() == 5)	{
                	fixedOutGoingPanel.update();
                }
                if (integerSelectionEvent.getSelectedItem() == 6)	{
                	chartsPanel.update();
                }
                if (integerSelectionEvent.getSelectedItem() == 7)	{
                	goalsPanel.update();
                }
            }
        });
	}
}
